//
//  CollectionTableViewCell.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/9.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "CollectionTableViewCell.h"

@implementation CollectionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpUI];
    }
    return self;
}
#pragma mark - 修改删除滑块颜色（小于ios11）
- (void)layoutSubviews
{
    [super layoutSubviews];
    
    for (UIView *subView in self.subviews) {
        if ([NSStringFromClass([subView class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) {
            ((UIView *)[subView.subviews firstObject]).backgroundColor = navBarColor;
        }
    }
}
- (void)setUpUI
{
    WeakSelf
    self.goodsImg = [[UIImageView alloc] init];
    _goodsImg.image = UIImageNamed(@"salesGoods");
    [self addSubview:_goodsImg];
    [_goodsImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(rateWidth(30));
        make.size.mas_offset(CGSizeMake(rateWidth(180), rateWidth(180)));
        make.centerY.equalTo(self);
    }];
    
    self.titleLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x323232) fontSize:15];
    _titleLB.numberOfLines = 0;
    [_titleLB sizeToFit];
    [self addSubview:_titleLB];
    [_titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.goodsImg.mas_right).offset(rateWidth(26));
        make.top.equalTo(weakSelf.goodsImg).offset(rateWidth(6));
        make.width.mas_lessThanOrEqualTo(@(rateWidth(420)));
        make.height.mas_lessThanOrEqualTo(@(rateHeight(80)));
    }];
    
    self.describeLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x909090) fontSize:12];
    [_describeLB sizeToFit];
    [self addSubview:_describeLB];
    [_describeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLB);
        make.top.equalTo(weakSelf.titleLB.mas_bottom).offset(rateWidth(15));
        make.width.mas_lessThanOrEqualTo(@(rateWidth(420)));
    }];
    
    self.priceLB = [UILabel labelWithText:@"￥199.00" textColor:UIColorFromRGB(0xf55555) fontSize:15];
    [_priceLB sizeToFit];
    [self addSubview:_priceLB];
    [_priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLB);
        make.bottom.equalTo(weakSelf.goodsImg).offset(-rateWidth(6));
    }];
    self.priceLB.hidden = YES;
    
    self.line = [[UIView alloc] init];
    _line.backgroundColor = globalGray;
    [self addSubview:_line];
    [_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(self);
        make.height.equalTo(@(rateWidth(2)));
    }];
}

@end
